package com.longge;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class kthDistinct {

    public String kthDistinct(String[] arr, int k) {
        HashMap<String, Integer> map = new LinkedHashMap<>();
        for (String s : arr) {
            map.put(s, map.getOrDefault(s, 0) + 1);
        }

        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            if (entry.getValue()==1){
                k--;
                if (k==0) return entry.getKey();
            }
        }
        return "";
    }
}
